/**
 * 通过全选按钮选择表格中的全部数据
 */
function setCheckedStatus() {
	var TableData = document.getElementById("listForm:listTable");
	var CheckAll = document.getElementById("listForm:listTable:selectAll");
	// 判断浏览器类型，如果是IE则使用table表格获取，否则通过ID获取
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null && CheckAll != null) {
			for (i = 1; i < TableData.rows.length; i++) {
				TableData.rows(i).cells(0).children.item(0).checked = CheckAll.checked;
			}
		}
	} else {
		if (TableData != null && CheckAll != null) {
			for (i = 0; i < TableData.rows.length - 1; i++) {
				document
						.getElementById("listForm:listTable:" + i + ":isSelect").checked = CheckAll.checked;
			}
		}
	}
}

/**
* 通过全选按钮选择表格中的全部数据
*/
function setCheckedStatus2() {
	var TableData = document.getElementById("listForm:listTable");
	var CheckAll = document.getElementById("listForm:listTable:selectAll");
	// 判断浏览器类型，如果是IE则使用table表格获取，否则通过ID获取
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null && CheckAll != null) {
			for (i = 1; i < TableData.rows.length-1; i++) {
				TableData.rows(i).cells(0).children.item(0).checked = CheckAll.checked;
			}
		}
	} else {
		if (TableData != null && CheckAll != null) {
			for (i = 0; i < TableData.rows.length - 1; i++) {
				document
						.getElementById("listForm:listTable:" + i + ":isSelect").checked = CheckAll.checked;
			}
		}
	}
}

/**
 *Tab页签
 */
function Show_TabADSMenu(tabadid_num,tabadnum){ 
        for(var i=0;i<7;i++){document.getElementById("tabadcontent_"+tabadid_num+i).style.display="none";} 
        for(var i=0;i<7;i++){document.getElementById("tabadmenu_"+tabadid_num+i).className="";} 
        document.getElementById("tabadmenu_"+tabadid_num+tabadnum).className="TasADSOn"; 
        document.getElementById("tabadcontent_"+tabadid_num+tabadnum).style.display="block"; 
}

function Show_TabADSMenu5(tabadid_num,tabadnum){ 
        for(var i=0;i<5;i++){document.getElementById("tabadcontent_"+tabadid_num+i).style.display="none";} 
        for(var i=0;i<5;i++){document.getElementById("tabadmenu_"+tabadid_num+i).className="";} 
        document.getElementById("tabadmenu_"+tabadid_num+tabadnum).className="TasADSOn"; 
        document.getElementById("tabadcontent_"+tabadid_num+tabadnum).style.display="block"; 
}
/**
 * 通过全选按钮选择表格中的全部数据,传入formId和tableId
 * IE8，FireFox3.5测试通过(lianghaiqi 20090826)
 */
function setCheckedStatusCustomer(formId, tableId) {
	var elem = formId + ":" + tableId;
	var TableData = document.getElementById(elem);
	var CheckAll = document.getElementById(elem + ":selectAll");
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null && CheckAll != null) {
			for (i = 1; i < TableData.rows.length; i++) {
				var ckbox = TableData.rows(i).cells(0).children.item(0);
				if (ckbox != null) {
					ckbox.checked = CheckAll.checked;
				}
			}
		}
	} else {
		if (TableData != null && CheckAll != null) {
			for ( var i = 0; i < TableData.rows.length; i++) {
				var objId = elem + ":" + i + ":isSelect";
				var ckbox = document.getElementById(objId);
				if (ckbox != null) {
					ckbox.checked = CheckAll.checked;
				}
			}
		}
	}
}
/**
 * 是否选择了记录
 */
function checkChooseItem(formId, tableId) {
		var elem = formId + ":" + tableId;
		var TableData = document.getElementById(elem);
		var CheckAll = document.getElementById(elem + ":selectAll");
		var j = 0;
		if (navigator.userAgent.indexOf("MSIE") > 0) {
			if (TableData != null && CheckAll != null) {
				for (i = 1; i < TableData.rows.length - 1; i++) {
					var ckbox = TableData.rows(i).cells(0).children.item(0);
					if (ckbox != null && ckbox.checked) {
						j++;
					}
				}
			}
		} else {
			if (TableData != null && CheckAll != null) {
				for ( var i = 0; i < TableData.rows.length - 1; i++) {
					var ckbox = document.getElementById(elem + ":" + i
							+ ":isSelect");
					if (ckbox != null && ckbox.checked) {
						j++;
					}
				}
			}
		}
		if (j == 0) {
			ymPrompt.errorInfo( {
				title : '操作错误信息',
				message : '请选择记录'
			});
			return false;
		} else {
			return true;
		}
}
 
 /**
  * 是否选择了记录
  */
 function checkChooseItemWithNo(formId, tableId, no) {
 		var elem = formId + ":" + tableId;
 		var TableData = document.getElementById(elem);
 		var CheckAll = document.getElementById(elem + ":selectAll");
 		var j = 0;
 		if (navigator.userAgent.indexOf("MSIE") > 0) {
 			if (TableData != null && CheckAll != null) {
 				for (i = 1; i < TableData.rows.length - no; i++) {
 					var ckbox = TableData.rows(i).cells(0).children.item(0);
 					if (ckbox != null && ckbox.checked) {
 						j++;
 					}
 				}
 			}
 		} else {
 			if (TableData != null && CheckAll != null) {
 				for ( var i = 0; i < TableData.rows.length - no; i++) {
 					var ckbox = document.getElementById(elem + ":" + i
 							+ ":isSelect");
 					if (ckbox != null && ckbox.checked) {
 						j++;
 					}
 				}
 			}
 		}
 		if (j == 0) {
 			ymPrompt.errorInfo( {
 				title : '操作错误信息',
 				message : '请选择记录'
 			});
 			return false;
 		} else {
 			return true;
 		}
 }
/**
 * 判断删除按钮是否选择了记录，以及提示是否删除,取消判断IE
 * IE8，FireFox3.5测试通过(lianghaiqi 20090826)
 */
function checkDeleteChooseItem(formId, tableId, obj) {
	var elem = formId + ":" + tableId;
	var TableData = document.getElementById(elem);
	var CheckAll = document.getElementById(elem + ":selectAll");
	var j = 0;
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null && CheckAll != null) {
			for (i = 1; i < TableData.rows.length; i++) {
				var ckbox = TableData.rows(i).cells(0).children.item(0);
				if (ckbox != null && ckbox.checked) {
					j++;
				}
			}
		}
	} else {
		if (TableData != null && CheckAll != null) {
			for ( var i = 0; i < TableData.rows.length - 1; i++) {
				var ckbox = document.getElementById(elem + ":" + i
						+ ":isSelect");
				if (ckbox != null && ckbox.checked) {
					j++;
				}
			}
		}
	}
	if (j == 0) {
		ymPrompt.errorInfo( {
			title : '操作错误信息',
			message : '请选择记录'
		});
		return false;
	} else {
		//			var res = ymPrompt.confirmInfo({title:'提示信息',message:'是否确认删除? '});
		// return confirm("是否确认删除? ");
		var res = confirm("是否确认删除? ");
		if (res == true) {
			obj.onclick();
		}
	}
}
//判断需要选择checkbox的按钮是否选择了记录
function checkSelectedItem(formId, tableId, obj) {
	var elem = formId + ":" + tableId;
	var TableData = document.getElementById(elem);
	var CheckAll = document.getElementById(elem + ":selectAll");
	var j = 0;
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null && CheckAll != null) {
			for (i = 1; i < TableData.rows.length; i++) {
				var ckbox = TableData.rows(i).cells(0).children.item(0);
				if (ckbox != null && ckbox.checked) {
					j++;
				}
			}
		}
	} else {
		if (TableData != null && CheckAll != null) {
			for ( var i = 0; i < TableData.rows.length - 1; i++) {
				var ckbox = document.getElementById(elem + ":" + i
						+ ":isSelect");
				if (ckbox != null && ckbox.checked) {
					j++;
				}
			}
		}
	}
	if (j == 0) {
		ymPrompt.errorInfo( {
			title : '操作错误信息',
			message : '请选择记录'
		});
		return false;
	} else {
		obj.onclick();
	}
}

/**
 * 判断删除按钮是否选择了记录，以及提示是否删除,取消判断IE
 * IE8，FireFox3.5测试通过(lianghaiqi 20090826)
 */
function checkDeleteChooseItem2(formId, tableId, obj) {
	var elem = formId + ":" + tableId;
	var TableData = document.getElementById(elem);
	var CheckAll = document.getElementById(elem + ":selectAll");
	var j = 0;
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null && CheckAll != null) {
			for (i = 1; i < TableData.rows.length; i++) {
				var ckbox = TableData.rows(i).cells(0).children.item(0);
				if (ckbox != null && ckbox.checked) {
					j++;
				}
			}
		}
	} else {
		if (TableData != null && CheckAll != null) {
			for ( var i = 0; i < TableData.rows.length - 1; i++) {
				var ckbox = document.getElementById(elem + ":" + i
						+ ":isSelect");
				if (ckbox != null && ckbox.checked) {
					j++;
				}
			}
		}
	}
	//如果没选择记录，提示
	if (j == 0) {
		ymPrompt.errorInfo( {
			title : '操作错误信息',
			message : '请选择记录'
		});
		return false;
	} else {
		//否则直接做删除
		return true;
	}
}

/**
 * 如果改变了选择框的值且不为空，则选中行首的checkbox
 */
function chooseCheckBox(obj, formId, tableId) {
	// objId形如resultForm:listTable:0:chooseFraudTp,那个0即为rowIndex
	var elem = formId + ":" + tableId + ":";
	var objId = obj.id;
	var rowIndex = objId.substring(objId.indexOf(":", 20) + 1, objId.indexOf(
			":", 22));
	if ('' == obj.value) {
		document.getElementById(elem + rowIndex + ":isSelect").checked = false;
	} else {
		document.getElementById(elem + rowIndex + ":isSelect").checked = true;
	}
}
 
//日期控件,yy-MM-dd：选择当前时间以前的
function selectBefTime() {
	WdatePicker( {
		maxDate :  '%y-%M-%d'
	});
}
//日期控件,yy-MM-dd
function selectFirstTime() {
	var vd5222 = $dp.$('listForm:d5222');
	WdatePicker( {
		onpicked : function() {
			vd5222.focus();
		},
		maxDate : '#F{$dp.$D(\'listForm:d5222\')}'
	});
}
function selectEndTime() {
	WdatePicker( {
		minDate : '#F{$dp.$D(\'listForm:d5221\')}'
	});
}
//不能小于第二个控件时间，并且不能小于传入日期时间
function selectStartTimeBeforDate(date) {
	var vd5222 = $dp.$('listForm:d5222');
	WdatePicker( {
		dateFmt : 'yyyy-MM-dd',
		onpicked : function() {
		vd5222.focus();
	    },
	    maxDate : date
	});
}
//不能大于第一个控件时间，并且不能小于传入日期时间
function selectEndTimeBeforDate(date) {
	WdatePicker( {
		dateFmt : 'yyyy-MM-dd',
		minDate : '#F{$dp.$D(\'listForm:d5221\')}',
		maxDate : date
	});
}
//如果页面上有两组日期控件，均为yy-MM-dd格式，第二组采用下面方法获得控件
function selectFirstTime2() {
	var vd5224 = $dp.$('listForm:d5224');
	WdatePicker( {
		dateFmt : 'yyyy-MM-dd',
		onpicked : function() {
			vd5224.focus();
		},
		maxDate:'#F{$dp.$D(\'listForm:d5224\')}'
	});
}
function selectEndTime2() {
	WdatePicker( {
		dateFmt : 'yyyy-MM-dd',
		minDate : '#F{$dp.$D(\'listForm:d5223\')}'
	});
}
//如果页面上有三组日期控件，均为yy-MM-dd格式，第三组采用下面方法获得控件
function selectFirstTime3() {
	var vd5226 = $dp.$('listForm:d5226');
	WdatePicker( {
		onpicked : function() {
			vd5226.focus();
		},
		maxDate:'#F{$dp.$D(\'listForm:d5226\')}'
	});
}
function selectEndTime3() {
	WdatePicker( {
		minDate : '#F{$dp.$D(\'listForm:d5225\')}'
	});
}
function selectFirstTime4() {
	var vd5224 = $dp.$('listForm:d5224');
	WdatePicker( {
		onpicked : function() {
			vd5224.focus();
			vd5224.value="";
		},
		minDate:'%y-%M-%d'
	});
   }
function selectEndTime4() {
WdatePicker( {
	minDate : '#F{$dp.$D(\'listForm:d5223\')}',
	maxDate:'#F{$dp.$D(\'listForm:d5223\',{M:6})}'		
});
}
//日期控件,yy-mm-dd hh:mm:ss
function selectFirstTimeAndSecond() {
	var vd5224 = $dp.$('listForm:d5224');
	WdatePicker( {
		autoPickDate : true,
		dateFmt : 'yyyy-MM-dd HH:mm:ss',
		onpicked : function() {
			vd5224.focus();
		},
		maxDate : '#F{$dp.$D(\'listForm:d5224\')}'
	});
}
function selectEndTimeAndSecond() {
	WdatePicker( {
		autoPickDate : true,
		dateFmt : 'yyyy-MM-dd HH:mm:ss',
		minDate : '#F{$dp.$D(\'listForm:d5223\')}'
	});
}
//日期控件,yy-mm-dd hh:mm:ss
function selectFirstTimeAndSecond2() {
	var vd5226 = $dp.$('listForm:d5226');
	WdatePicker( {
		autoPickDate : true,
		dateFmt : 'yyyy-MM-dd HH:mm:ss',
		onpicked : function() {
			vd5226.focus();
		},
		maxDate : '#F{$dp.$D(\'listForm:d5226\')}'
	});
}
function selectEndTimeAndSecond2() {
	WdatePicker( {
		autoPickDate : true,
		dateFmt : 'yyyy-MM-dd HH:mm:ss',
		minDate : '#F{$dp.$D(\'listForm:d5225\')}'
	});
}
//日期控件，格式为yyyy-MM
function selectFirstDate() {
	var vd5222 = $dp.$('listForm:d5222');
	WdatePicker( {
		dateFmt : 'yyyy-MM',
		onpicked : function() {
			vd5222.focus();
		},
		maxDate : '#F{$dp.$D(\'listForm:d5222\')}'
	});
}
function selectEndDate() {
	WdatePicker( {
		dateFmt : 'yyyy-MM',
		minDate : '#F{$dp.$D(\'listForm:d5221\')}'
	});
}

/**
* 通过全选按钮选择表格中的全部数据
*/
function checkSelectAllStatus(listFormId,listTableId) {
	var TableData = document.getElementById(listFormId+":"+listTableId);
	if(TableData==null){
		TableData = document.getElementById("listForm:listTable");
	}
	var CheckAll = document.getElementById(listFormId+":"+listTableId+":selectAll");
	if(CheckAll==null){
		CheckAll = document.getElementById("listForm:listTable:selectAll");
	}
	//var TableData = document.getElementById("listForm:listTable");
	//var CheckAll = document.getElementById("listForm:listTable:selectAll");
	// 判断浏览器类型，如果是IE则使用table表格获取，否则通过ID获取
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null && CheckAll != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				var disabledValue=TableData.rows(i).cells(0).children.item(0).disabled;
				if(TableData.rows(i).cells(0).children.item(0).checked==false){
					CheckAll.checked=false;
					break;
				}else{
					CheckAll.checked=true;
				}
			}	
		}
	}
}

/**
* 通过全选按钮选择表格中的全部数据
*/
function checkSelectAllStatusWithNo(listFormId,listTableId,no) {
	var TableData = document.getElementById(listFormId+":"+listTableId);
	if(TableData==null){
		TableData = document.getElementById("listForm:listTable");
	}
	var CheckAll = document.getElementById(listFormId+":"+listTableId+":selectAll");
	if(CheckAll==null){
		CheckAll = document.getElementById("listForm:listTable:selectAll");
	}
	//var TableData = document.getElementById("listForm:listTable");
	//var CheckAll = document.getElementById("listForm:listTable:selectAll");
	// 判断浏览器类型，如果是IE则使用table表格获取，否则通过ID获取
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null && CheckAll != null) {
			for (i = 1; i < TableData.rows.length - no; i++) {
				var disabledValue=TableData.rows(i).cells(0).children.item(0).disabled;
				if(TableData.rows(i).cells(0).children.item(0).checked==false){
					CheckAll.checked=false;
					break;
				}else{
					CheckAll.checked=true;
				}
			}	
		}
	}
}
/**
 * 收单规则实例提示框判断函数
 */
function showRuleInsPanel(){
		 var showPanel = document.getElementById("listForm:showPanel").value; 
	     if(showPanel=='delete'){
	 	 	Richfaces.showModalPanel('modalPanel1');
	 	 }  else if(showPanel=='success') {
	 		 Richfaces.showModalPanel('modalPanel2');
	 	 }  else if(showPanel=='update') {
	 		 Richfaces.showModalPanel('modalPanel3');
	 	 }  else if(showPanel=='batchupdate') {
	 		 Richfaces.showModalPanel('modalPanel4');
	 	 }
	 }
/**
 * 收单规则模板提示框判断函数
 */
function showRuleTemplatePanel(){
		 var showPanel = document.getElementById("userForm:showPanel").value; 
	     if(showPanel=='modify'){
	 	 	Richfaces.showModalPanel('modalPanel1');
	 	 }  else if(showPanel=='success') {
	 		 Richfaces.showModalPanel('modalPanel2');
	 	 }
	 }
/**
 * 收单规则模板分配提示框判断函数
 */
function showRuleAssignPanel(){
		 var showPanel = document.getElementById("userForm:showPanel").value; 
	     if(showPanel=='add'){
	 	 	Richfaces.showModalPanel('modalPanel1');
	 	 }  else if(showPanel=='cover') {
	 		 Richfaces.showModalPanel('modalPanel2');
	 	 }  else if(showPanel=='success') {
	 		 Richfaces.showModalPanel('modalPanel3');
	 	 }
	 }
/**
 * poc报送提示框判断函数
 */
function showPOCPanel(){
		 var showPanel = document.getElementById("userForm:showPanel").value; 
	     if(showPanel=='add'){
	 	 	Richfaces.showModalPanel('modalPanel1');
	 	 }  else if(showPanel=='success') {
	 		 Richfaces.showModalPanel('modalPanel2');
	 	 }
	 }
/**
 * 案例手工新增提示框判断函数
 */
function showCaseManuAddPanel(){
		 var showPanel = document.getElementById("userForm:showPanel").value; 
	     if(showPanel=='add'){
	 	 	Richfaces.showModalPanel('modalPanel1');
	 	 }  else if(showPanel=='success') {
	 		 Richfaces.showModalPanel('modalPanel2');
	 	 }
	 }
/**
 * 历史交易查询处理提示框判断函数
 */
function showHistManagePanel(){
		 var showPanel = document.getElementById("mainForm:showPanel").value; 
	     if(showPanel=='update'){
	 	 	Richfaces.showModalPanel('modalPanel1');
	 	 }  else if(showPanel=='success') {
	 		 Richfaces.showModalPanel('modalPanel2');
	 	 }
	 }
/**
 * 案例处理提示框判断函数
 */
function showAcqCasePanel(){
		 var showPanel = document.getElementById("userForm:showPanel").value; 
	     if(showPanel=='proc'){
	 	 	Richfaces.showModalPanel('modalPanel1');
	 	 }  else if(showPanel=='assign') {
	 		 Richfaces.showModalPanel('modalPanel3');
	 	 }  else if(showPanel=='success') {
	 		 Richfaces.showModalPanel('modalPanel2');
	 	 }  else if(showPanel=='batch') {
	 		 Richfaces.showModalPanel('modalPanel4');
	 	 }
	 }
/**
 * 案例批量文件处理提示框判断函数
 */
function showAcqBatchCasePanel(){
		 var showPanel = document.getElementById("listForm:showPanel").value; 
	     if(showPanel=='proc'){
	 	 	Richfaces.showModalPanel('modalPanel1');
	 	 }  else if(showPanel=='assign') {
	 		 Richfaces.showModalPanel('modalPanel3');
	 	 }  else if(showPanel=='success') {
	 		 Richfaces.showModalPanel('modalPanel2');
	 	 }  else if(showPanel=='batch') {
	 		 Richfaces.showModalPanel('modalPanel4');
	 	 }
	 }
/**
 * 可疑交易查询处理提示框判断函数
 */
function showSusTransPanel(){
		 var showPanel = document.getElementById("listForm:showPanel").value; 
	     if(showPanel=='assign'){
	 	 	Richfaces.showModalPanel('modalPanel1');
	 	 }  else if(showPanel=='delay') {
	 		 Richfaces.showModalPanel('modalPanel3');
	 	 }  else if(showPanel=='delayErr') {
	 		 Richfaces.showModalPanel('modalPanel4');
	 	 }  else if(showPanel=='addComment') {
	 		 Richfaces.showModalPanel('modalPanel5');
	 	 }  else if(showPanel=='saveInvgtResult') {
	 		 Richfaces.showModalPanel('modalPanel6');
	 	 }  else if(showPanel=='highRiskCard') {
	 		 Richfaces.showModalPanel('modalPanel7');
	 	 }  else if(showPanel=='highRiskMchnt') {
	 		 Richfaces.showModalPanel('modalPanel8');
	 	 }  else if(showPanel=='expCard') {
	 		 Richfaces.showModalPanel('modalPanel9');
	 	 }  else if(showPanel=='expMchnt') {
	 		 Richfaces.showModalPanel('modalPanel10');
	 	 }  else if(showPanel=='success') {
	 		 Richfaces.showModalPanel('modalPanel2');
	 	 }
	 }
/**
 * 设置信息共享批量上传处理时，显示loading图片
 */
function setImage() {
		var img = document.listForm.loading;
		img.style.display="block";
    }
 
 /**
  * 设置信息共享批量上传处理时，显示loading图片
  */
 function setTheImage(imgId) {
 		document.getElementById(imgId).style.display="block";
 		
     }
/**
 * 案例批量上传处理时，显示loading图片
 */
function setAcqCaseProcImage() {
		var img = document.userForm.loading;
		img.style.display="block";
    }
 
 Richfaces.showModalPanel = function (id, opts, event) {
		var panel = $(id);
		if (!panel) {
			panel = Richfaces.findModalPanel(id);
		}
		panel.component.show(event, opts);

	};